<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="../style/journal.css" type="text/css" />
<style type="text/css"><!--
.googleadsense {
	margin: 2px;
	padding: 0px;
//--></style><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-65008-1";
urchinTracker();
</script><title>Day [05.3.29] POD && Pugs</title>
</head>
<body>
<a href="index.html">Journal</a>(2005) | <a href="../blog/"><b>Blog</b></a>(2006) | <a href="http://www.fayland.org/cgi-bin/random_link.pl">RandomLink</a> | <a href="AboutFayland.html">WhoAmI</a> | <a href="LiveBookmark.html">LiveBookmark</a> | <a href="http://www.fayland.org/">HomePage</a>
<p><&lt;Previous: <a href="050328_PerlChina.html">Yap, I recieved a book</a>&nbsp;&nbsp;>>Next: <a href="ShareURL0503.html">Share the URLs with u (Mar. 2005)</a></p>
<h1>Day [05.3.29] POD && Pugs</h1>
<div class='content'>
<p>Category: <a href='Diary.html'>Diary</a> &nbsp; Keywords: <b>pod pugs</b></p>Hoowa 说 Perl::Pugs 项目要 port 些 Perl 5 模块到 Pugs 上，叫我起个头。真是为难死我了。<br>
他给我找了个纯 Perl 模块 <a href='http://search.cpan.org?Digest::Perl::MD5'>Digest::Perl::MD5</a> 让我试着移植。<p>

Digest::Perl::MD5 里有段 __DATA__ 我不知道到 Perl 6 中咋变化，于是翻阅了下 <a href='dev.perl.org/perl6/synopsis/S02.html'>Synopsis 2: Atom</a>. 里面倒是说了用 =begin DATA 写入和用 (%|@|$)=DATA 来获取。<br>
在 Pugs 里试了一下，发现还没实现。于是想着先给 pugs 写个 t 测试文件。因为 Synopsis 2 里我看不太懂，就想着去找点资料。Google Search 了下，找到些资料：
<ul>
<li><a href='http://www.nntp.perl.org/group/perl.perl6.announce/263'>http://www.nntp.perl.org/group/perl.perl6.announce/263</a>
<li><a href='http://aspn.activestate.com/ASPN/Mail/Message/perl6-language/2524719'>http://aspn.activestate.com/ASPN/Mail/Message/perl6-language/2524719</a>
</ul>

这一看不打紧那，可把我给弄糊涂了。<br>
第一个是对 Pod 的建议改革。The Predefined POD Streams are C<perl>, C<data>, and C<doc>. 个人觉得说得挺不错的。<br>
第二帖因为不完整，所以在新闻组 <a href='http://www.nntp.perl.org/group/perl.perl6.language'>perl.perl6.language</a> 里搜索了下。发现这是个很长的帖子：A more extensible/flexible POD (ROUGH-DRAFT). 里面有 Pod vs Kwid, 个人觉得 Kwid 很棒。<p>

我不打算把这个 t 文件传到 pugs 里了。一是因为还不完整，只有测试了一部分 @=DATA, 二是我也不知道 Pod 在 Perl 6 中到底是如何。<br>
把这个 t 文件列于下：
<pre><code>
#!/usr/bin/pugs

use v6;
require Test;

plan 6;

# L&lt;S02/"Literals">
# L&lt;S02/"Molecules" /Multiline comments/>

todo_eval_ok '
=begin DATA LABEL1
LABEL1.1
LABEL1.2
LABEL1.3
=end DATA

=begin DATA LABEL2
LABEL2.1
LABEL2.2
=end DATA
', "=begin DATA works";

todo_eval_is('%=DATA&lt;LABEL1>[0]', 'LABEL1.1', '@=DATA&lt;LABEL1>[0] is correct');
todo_eval_is('%=DATA&lt;LABEL1>[2]', 'LABEL1.3', '@=DATA&lt;LABEL1>[2] is correct');
todo_eval_is('~ %=DATA&lt;LABEL1>', 'LABEL1.1LABEL1.2LABEL1.3', '~ %=DATA&lt;LABEL1> is correct');

todo_eval_is('~ $=LABEL2', 'LABEL2.1LABEL2.2', '~ $=LABEL2 is correct');
todo_eval_is('$=LABEL2[1]', 'LABEL2.2', '$=LABEL2[1] is correct');
</code></pre>

最后还发现我以前写的部分关于 x= 的测试可以运行了。 Pugs 发展得够快的。
<pre>
# test x=
my $twin = 'Lintilla';
ok(eval '$twin x= 2;', 'operator x= for string works');
is ($twin, 'LintillaLintilla', 'operator x= for string repeats correct');

my @array = (4, 2);
ok(eval '@array xx= 2;', 'operator xx= for list works');
is (@array[0], 4, 'operator xx= for list repeats correct');
is (@array[3], 2, 'operator xx= for list repeats correct');
is (+@array, 4, 'operator xx= for list created the right size');
</pre></div>
<p><&lt;Previous: <a href="050328_PerlChina.html">Yap, I recieved a book</a>&nbsp;&nbsp;>>Next: <a href="ShareURL0503.html">Share the URLs with u (Mar. 2005)</a></p>
<p><strong>Options:</strong> <a href='http://del.icio.us/post?title=Day%20%5B05.3.29%5D%20POD%20&&%20Pugs&url=http://www.fayland.org/journal/050329.html'>+Del.icio.us</a></p>
<strong>Related items</strong>
<ul><li><a href='POD.html'>怎么写POD</a> < <span class='digit'>2005-01-14 00:40:37</span> ></li><li><a href='pod2cn.html'>Perl 核心模块中文化</a> < <span class='digit'>2005-11-20 21:43:52</span> ></li><li><a href='050308.html'>weird thing with nmake pugs</a> < <span class='digit'>2005-03-08 23:53:21</span> ></li><li><a href='050604.html'>fail to embed parrot in pugs(Resolved)</a> < <span class='digit'>2005-06-04 19:09:35</span> ></li></ul>
Created on <span class="digit">2005-03-29 16:04:20</span>, Last modified on <span class="digit">2005-04-24 22:21:06</span><br />
Copyright 2004-2005 All Rights Reserved. Powered by <a href="Eplanet.html">Eplanet</a> && <a href='http://catalyst.perl.org'>Catalyst</a> 5.62.
</body>
</html>